<?php

include_once("../controller/sala_controller_class.php");

$ident = $_POST['ident'];
$andar = $_POST['andar'];
$predio = $_POST['predio'];

if(empty($ident)){
    echo "<script>alert('Preencha a Identificação')</script>";
}elseif(empty($andar)){
    echo "<script>alert('Preencha o Andar')</script>";
}elseif(empty($predio)){
    echo "<script>alert('Preencha o Prédio')</script>";
}else{
    
    $objSala = new SalaController();
    
    if($objSala->cadastrar($predio, $ident, $andar)){
        $listSala = $objSala->selecionarSalasPorPredioJSON($predio);

        echo json_encode($listSala);
    }
}

